<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ page import="sky.domain.Flight" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    SimpleDateFormat formatter4 = new SimpleDateFormat("dd.MM.yyyy HH:mm");
    Date date = formatter.parse(((Flight)request.getAttribute("flight")).getDepartureDate().toString());
    Date date1 = formatter.parse(((Flight)request.getAttribute("flight")).getDestinationDate().toString());
%>
<div class="flightInfo">
    <div class="flightInfoHeader">
        <span class="flightInfoHeader" style="width: 12px">${flight.id}</span>
        <span class="flightInfoHeader" style="width: 90px">${flight.departureAirport.name}</span>
        <span class="flightInfoHeader" style="width: 150px"><%= formatter4.format(date) %></span>
        <span class="flightInfoHeader" style="width: 10px">-</span>
        <span class="flightInfoHeader" style="width: 90px">${flight.destinationAirport.name}</span>
        <span class="flightInfoHeader" style="width: 65px">
            <c:if test="${ticketType eq 'Econom'}">
                ${flight.economCost}
            </c:if>
            <c:if test="${ticketType eq 'Bussiness'}">
                ${flight.bussinessCost}
            </c:if>
            <c:if test="${ticketType eq 'FirstClass'}">
                ${flight.firstClassCost}
            </c:if>
        </span>
        <span style="width: 60px; text-align: left">&nbsp;</span>
        <span class="flightInfoHeader">
            <a href="/flights/book/${flight.id}">[>]</a>
        </span>
    </div>
    <div class="flightInfoContent">
        <div class="left" style="background-color: antiquewhite">
            <p><spring:message code="flightInfo.airport" />:
                <a href="
                    <c:url value="/airport">
                        <c:param name="id" value="${flight.departureAirport.id}" />
                    </c:url> ">
                    ${flight.departureAirport.name}</a>
            </p>
            <p><spring:message code="flightInfo.city" />:
                <a href="
                    <c:url value="/city">
                        <c:param name="id" value="${flight.departureAirport.city.id}" />
                    </c:url> ">
                    ${flight.departureAirport.city.name}</a>
            </p>
            <p><spring:message code="flightInfo.country" />:
                <a href="
                    <c:url value="/country">
                        <c:param name="id" value="${flight.departureAirport.city.country.id}" />
                    </c:url> ">
                    ${flight.departureAirport.city.country.name}</a>
            </p>
            <p><spring:message code="flightInfo.DepDate" />: ${flight.departureDate}</p>
        </div>
        <div class="right">
            <p><spring:message code="flightInfo.airport" />:
                <a href="
                    <c:url value="/airport">
                        <c:param name="id" value="${flight.destinationAirport.id}" />
                    </c:url> ">
                    ${flight.destinationAirport.name}</a>
            </p>
            <p><spring:message code="flightInfo.city" />:
                <a href="
                    <c:url value="/city">
                        <c:param name="id" value="${flight.destinationAirport.city.id}" />
                    </c:url> ">
                    ${flight.destinationAirport.city.name}</a>
            </p>
            <p><spring:message code="flightInfo.country" />:
                <a href="
                    <c:url value="/country">
                        <c:param name="id" value="${flight.destinationAirport.city.country.id}" />
                    </c:url> ">
                    ${flight.destinationAirport.city.country.name}</a>
            </p>
            <p><spring:message code="flightInfo.DesDate" />: ${flight.destinationDate}</p>
        </div>
        <div class="sub">
            <p><spring:message code="flightInfo.plane" />:
                <a href="
                    <c:url value="/plane">
                    <c:param name="id" value="${flight.plane.id}" />
                    </c:url>">
                    ${flight.plane.name}</a></p>
            <p><spring:message code="flightInfo.places" />: ${flight.freeAllPlaces}</p>
            <p><spring:message code="flightInfo.minCost" />: ${flight.economCost}</p>
        </div>
    </div>
</div>